home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 2.iso / dist / fw_libxml.idb / usr / freeware / include / gnome-xml / xmlmemory.h.z / xmlmemory.h
C/C++ Source or Header  |  2001-04-12  |  2KB  |  75 lines

  1. /*
  2.  * xmlmemory.h: interface for the memory allocation debug.
  3.  *
  4.  * Daniel.Veillard@w3.org
  5.  */
  6.  
  7.  
  8. #ifndef _DEBUG_MEMORY_ALLOC_
  9. #define _DEBUG_MEMORY_ALLOC_
  10.  
  11. #define NO_DEBUG_MEMORY
  12.  
  13. #ifdef NO_DEBUG_MEMORY
  14. #ifdef HAVE_MALLOC_H
  15. #include <malloc.h>
  16. #endif
  17.  
  18. #define xmlFree(x) free((x))
  19. #define xmlMalloc(x) malloc(x)
  20. #define xmlRealloc(p, x) realloc((p), (x))
  21. #define xmlMemStrdup(x) strdup((x))
  22. #define xmlInitMemory()
  23. #define xmlMemUsed()
  24. #define xmlInitMemory()
  25. #define xmlMemoryDump()
  26. #define xmlMemDisplay(x)
  27. #define xmlMemShow(x, d)
  28.  
  29. #else /* ! NO_DEBUG_MEMORY */
  30. #include <stdio.h>
  31.  
  32. /* #define DEBUG_MEMORY */ /* */
  33.  
  34. #define DEBUG_MEMORY_LOCATION
  35.  
  36. #ifdef DEBUG
  37. #ifndef DEBUG_MEMORY
  38. #define DEBUG_MEMORY
  39. #endif
  40. #endif
  41.  
  42. #define MEM_LIST /* keep a list of all the allocated memory blocks */
  43.  
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. int    xmlInitMemory    (void);
  48. void *    xmlMalloc    (int size);
  49. void *    xmlRealloc    (void *ptr,
  50.              int size);
  51. void    xmlFree        (void *ptr);
  52. char *    xmlMemStrdup    (const char *str);
  53. int    xmlMemUsed    (void);
  54. void    xmlMemDisplay    (FILE *fp);
  55. void    xmlMemShow    (FILE *fp, int nr);
  56. void    xmlMemoryDump    (void);
  57. int    xmlInitMemory    (void);
  58.  
  59. #ifdef DEBUG_MEMORY_LOCATION
  60. #define xmlMalloc(x) xmlMallocLoc((x), __FILE__, __LINE__)
  61. #define xmlRealloc(p, x) xmlReallocLoc((p), (x), __FILE__, __LINE__)
  62. #define xmlMemStrdup(x) xmlMemStrdupLoc((x), __FILE__, __LINE__)
  63.  
  64. extern void *    xmlMallocLoc(int size, const char *file, int line);
  65. extern void *    xmlReallocLoc(void *ptr,int size, const char *file, int line);
  66. extern char *    xmlMemStrdupLoc(const char *str, const char *file, int line);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif /* DEBUG_MEMORY_LOCATION */
  71. #endif /* ! NO_DEBUG_MEMORY */
  72.  
  73. #endif  /* _DEBUG_MEMORY_ALLOC_ */
  74.  
  75.